package com.fruit.controller.app.order;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fruit.controller.base.BaseController;
import com.fruit.pojo.shopping.Shopping;
import com.fruit.service.order.OrderConfirmManager;
import com.fruit.util.ResultInfo;
/**
 * APP订单controller
 * 
 * @author 
 *
 */
@Controller
@RequestMapping(value = "/app/order/confirmOrder")
public class OrderConfirmController extends BaseController{

	
	@Autowired
	private OrderConfirmManager orderConfirmService;
	
	@RequestMapping(value="/valication",method = { RequestMethod.POST,RequestMethod.GET })
	@ResponseBody
	public Map<String, Object> valication(Shopping shopping){
		Map<String, Object> resMap = new HashMap<String, Object>();
		try{
		//校验购物车产品类型
		resMap = orderConfirmService.createValicationShopping(shopping);
		}catch(Exception e){
			this.logError(logger, e.getMessage());
			resMap.put("result", this.initResult(ResultInfo.ERROR, "expection", "系统繁忙!"));
		}
		return resMap;
		
	}
	
	@RequestMapping
	@ResponseBody
	public Map<String, Object> confirmOrder(Shopping shopping){
		Map<String, Object> resMap = new HashMap<String, Object>();
		try{
			resMap = orderConfirmService.getConfirmManager(shopping);
		}catch(Exception e){
			this.logError(logger, e.getMessage());
			resMap.put("result", this.initResult(ResultInfo.ERROR, "expection", "系统繁忙!"));
		}
		return resMap;
	}
}
